//
//  WXBaMeiDaShanCollectionViewCell.m
//  Big Show
//
//  Created by dlios on 15-5-18.
//  Copyright (c) 2015年 Big_Q. All rights reserved.
//

#import "WXBaMeiDaShanCollectionViewCell.h"
#import "UIImageView+WebCache.h"

#define WIDTH [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHT [UIScreen mainScreen].bounds.size.height / 667


@interface WXBaMeiDaShanCollectionViewCell ()
@property (nonatomic, retain) UIImageView *imageView;
@property (nonatomic, retain) UILabel *label;


@end
@implementation WXBaMeiDaShanCollectionViewCell
- (void)dealloc
{
    [_imageView release];
    [_label release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
       
        
        self.imageView = [[UIImageView alloc] init];
//        self.imageView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_imageView];
        [_imageView release];
        
        self.label = [[UILabel alloc] init];
//        _label.backgroundColor = [UIColor lightGrayColor];
        _label.textColor = [UIColor blackColor];
        [_label setFont:[UIFont systemFontOfSize:14]];
        [self.contentView addSubview:_label];
        [_label release];
    }
    return self;
}

-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    
    _imageView.frame = CGRectMake(0, 0, self.contentView.bounds.size.width, self.contentView.bounds.size.height-HEIGHT* 30);
    _label.frame = CGRectMake(0, _imageView.frame.size.height+_imageView.frame.origin.y, _imageView.frame.size.width, HEIGHT* 30);
}

-(void)setDic:(NSDictionary *)dic
{
    if (_dic != dic) {
        [_dic release];
        _dic = [dic retain];
    }

    [_imageView sd_setImageWithURL:[NSURL URLWithString:[_dic objectForKey:@"pic_url"] ] placeholderImage:[UIImage imageNamed:@"占位图.jpg"]];
    _label.text = [_dic objectForKey:@"title"];
}
@end
